package com.salt.admin.api.feign.client;

import com.salt.admin.api.feign.hystrix.UserClientHystrix;
import com.salt.admin.api.feign.interceptor.FeignTokenInterceptor;
import com.salt.admin.api.model.DataRule;
import com.salt.admin.api.model.Role;
import com.salt.admin.api.model.User;
import com.salt.common.constant.Common;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @Description 管理中心USER远程调用接口
 * @Author salt
 * @Date 2020/7/28 16:45
 * @Version 1.0
 */
@Repository
@FeignClient(name = Common.Service.SALT_ADMIN_SERVICE_NAME,
        path = Common.Service.SALT_ADMIN_USER_URL_PREFIX,
        fallbackFactory = UserClientHystrix.class,
        configuration = FeignTokenInterceptor.class)
public interface UserClient {

    @GetMapping("get")
    public User getUser();

    @PostMapping("queryByIds")
    public List<User> queryByIds(@RequestParam("ids") List<String> ids);

    @PostMapping("getById")
    public User get(@RequestParam("id") String id);

    @PostMapping("name")
    public User getByUserName(@RequestParam("name") String name);

    @GetMapping("getDataRuleList")
    public List<DataRule> getDataRuleList();

    @GetMapping("getRoleList")
    public List<Role> getRoleList();

    @GetMapping("getUserByLoginName")
    public User getUserByLoginName(@RequestParam("loginName") String loginName);

    @GetMapping("findUserByOfficeId")
    public List<User> findUserByOfficeId(@RequestParam("id") String id);

    @PostMapping("findList")
    public List<User> findList(User user);

    @PostMapping("getUserIdByRoleIds")
    public List<String> getUserIdByRoleIds(@RequestParam("roleIds") List<String> roleIds);
}
